export function arrayRemove<T>(target: T[], comparison: (value: T, index: number) => boolean, once?: boolean) {
  const removed: T[] = []
  for (let i = 0; i < target.length; ) {
    if (comparison(target[i], i)) {
      removed.push(target.splice(i, 1)[0])
      if (once) break
    } else {
      i++
    }
  }

  return { target, removed }
}
